# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=phoss
_pkgname=PHoss
pkgver=0.1.13
pkgrel=7
pkgdesc='Sniffer designed to find HTTP, FTP, LDAP, Telnet, IMAP4, VNC and POP3 logins.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-cracker' 'blackarch-sniffer')
url='http://194.150.168.69/phoss'
license=('custom')
depends=('libpcap')
makedepends=('make' 'gcc')
source=("http://194.150.168.69/phoss/${_pkgname}_src.tar.gz"
        "http://194.150.168.69/phoss/${_pkgname}.diff")
sha512sums=('2616d573495d0bcc0f510ee4fdabd80c21ba3a0d6dd858c42a8e3c51bb074afb389a4d3466c3a5351949287b842ff874ffd2d261cc84204c5a021bd04cd274ed'
            '959c08b9cf5643615241cab954c309773e3f00bf23576a169fe7a06018430abe96201d4994224a1a30e28255a0962dbd7b42bbe49a918325f9ac454773151b95')

prepare() {
  cd $_pkgname

  patch -Np1 < "$srcdir/$_pkgname.diff"
  sed -i "s|#include <net/bpf.h>|#include <pcap/bpf.h>|" main.c
}

build() {
  cd $_pkgname

  make OPTIMI="$CFLAGS -fcommon"
}

package() {
  cd $_pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -aR $_pkgname "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./$_pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

